extends State
class_name Playeridle

var gravity:float = Autoload.gravity
@onready var player_sprite: AnimatedSprite2D = $"../../PlayerSprite"

func enter():
	print("进入待机状态") #测试用，可删
	character.velocity.x = 0
	
func update(delta:float):
	player_sprite.play("Idle")
	if InputBuffer.has_buffered_input("玩家跳跃") and character.is_on_floor():
		InputBuffer.consume_buffered_input("玩家跳跃")
		transition_requested.emit("Playerjump")
	if InputBuffer.has_buffered_input("玩家向左走") or InputBuffer.has_buffered_input("玩家向右走"):
		InputBuffer.consume_buffered_input("玩家向左走")
		InputBuffer.consume_buffered_input("玩家向右走")
		transition_requested.emit("Playerwalk")
	#if InputBuffer.has_buffered_input("冲刺") and Autoload.dashflag == true:
		#InputBuffer.consume_buffered_input("冲刺")
		#transition_requested.emit("Playerdash")
		
func physics_update(delta:float):
	if !character.is_on_floor():
		Autoload.wolf_time -= delta
	character.velocity.y += gravity * delta
	if character.is_on_floor():
		if Autoload.dashflag == false:
			Autoload.dashflag = true
		Autoload.wolf_time = Autoload.wolf_time_stander
	character.move_and_slide()
		
